<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  
</head>
<body>
  <div id="app">
    组件1
    <input type="radio" value="CommonHead" v-model="com">
    组件2
    <input type="radio" value="CommonHead2" v-model="com">
    <component :is="com"></component>
  </div>
  <script src="./vue.global.js"></script>
  <script>
    const { createApp } = Vue;
    // 应用实例
    const app = createApp({
      data(){
        return {
          com: 'CommonHead'
        }
      }
    });
    const CommonHead = {
      // 模板视图
      template: `
        <div>
          <h2>这是组件1</h2>
        </div>
      `
    }
    app.component('CommonHead', CommonHead)
    const CommonHead2 = {
      // 模板视图
      template: `
        <div>
          <h2>这是组件2</h2>
        </div>
      `,
      
    }
    app.component('CommonHead2', CommonHead2)
    app.mount('#app')
  </script>
</body>
</html>